package com.bh.web.controller.order;

import com.bh.common.annotation.Log;
import com.bh.common.core.controller.BaseController;
import com.bh.common.core.domain.AjaxResult;
import com.bh.common.enums.BusinessType;
import com.bh.order.domain.JcOrderTrack;
import com.bh.order.service.IJcOrderTrackService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 订单追踪Controller
 *
 * @author slx
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/order/orderTrack")
public class JcOrderTrackController extends BaseController {
    @Autowired
    private IJcOrderTrackService jcOrderTrackService;

    /**
     * 查询订单追踪列表
     */
    @ApiOperation("查询订单追踪列表")
    @GetMapping("/listByOrderId/{orderId}")
    public AjaxResult listByOrderId(@PathVariable Long orderId) {
        return success(jcOrderTrackService.selectJcOrderTrackListByOrderId(orderId));
    }

    /**
     * 获取订单追踪详细信息
     */
    @ApiOperation("获取订单追踪详细信息")
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(jcOrderTrackService.selectJcOrderTrackById(id));
    }

    /**
     * 新增订单追踪
     */
    @ApiOperation("新增订单追踪")
    @Log(title = "订单追踪", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JcOrderTrack jcOrderTrack) {
        return toAjax(jcOrderTrackService.insertJcOrderTrack(jcOrderTrack));
    }
}
